﻿using SportsStore.Domain.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SportsStore.WebUI.Controllers
{
    public class NavController : Controller
    {
        private IProductsRepository repository;

        public NavController(IProductsRepository repo)
        {
            repository = repo;
        }

        // GET: Nav
        public ActionResult Index()
        {
            return View();
        }
        //public string Menu() {
        //    return "Hello from NavController";
        //}
        //public PartialViewResult Menu(string category=null,bool horizontalLayout=false)
        //string viewName = horizontalLayout ? "MenuHorizontal" : "Menu";
        //return PartialView(viewName,categories);
        public PartialViewResult Menu(string category = null)
        {
            ViewBag.SelectedCategory = category;
            IEnumerable<string> categories = repository.Products
                .Select(x => x.Category)
                .Distinct()
                .OrderBy(x => x);

           
            return PartialView("FlexMenu", categories);

        }

    }
}